<%@ Page Title="Job Control Panel" Language="C#" MasterPageFile="~/Views/Shared/Employee.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<DomainModel.Entities.Job>>" %>

<asp:Content ContentPlaceHolderID="TitleContent" runat="server">
	Job Control Panel
</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">

<% using (Html.BeginForm("Index", "JobsManagement"))
   { %>
   
   <% if (ViewData["error"] != "") {  %>
        <p><label class="staffingexperterror" for="JobTitle"><%= Html.Encode(TempData["error"])%></label></p>
   <% } %>
   
    <h2>Existing Jobs</h2>
     
    <table class="staffingexpert" style="width: 650px" cellspacing="0" id="JobsTable">
        <thead>
        <tr>
            <th>Title</th>
            <th>Description</th>
            <th>Salary</th>
            <th>Actions</th>
       </tr>
       </thead>
       <tbody>
        <% foreach (var item in Model)
           { %>
             <tr>
                <td style="width: 180px; white-space: "><%= Html.Encode(item.JobTitle) %></td>               
                <td style="width: 250px; white-space: "><%= Html.Encode(item.JobDescription) %></td>
                <td style="width: 70px; white-space: "><%= Html.Encode(item.Salary) %></td>
                <td style="width: 150px">
                    <%= Html.ActionLink("Edit", "Edit", new { item.JobID })%> |
                    <%= Html.ActionLink("Delete", "Delete", new { item.JobID })%> 
                    <br/><%= Ajax.ActionLink("View Questions", "ViewQuestions", new { item.JobID }, new AjaxOptions { UpdateTargetId = "QuestionsTableDiv", OnSuccess = "UpdateTable" })%> 
                    <br/><%= Html.ActionLink("Attach/Detach Questions", "AttachDetachQuestion", new { item.JobID })%>
                </td>
            </tr>      
        <% } %>
    </tbody>
    </table>
    
    <script type="text/javascript">
            function UpdateTable() {
                var t = new ScrollableTable(document.getElementById('QuestionsTable'), 120);
            }
    </script>
    
    <script type="text/javascript">
        var t = new ScrollableTable(document.getElementById('JobsTable'), 220);
    </script>

    <p><%= Html.ActionLink("Add a new job title", "Create")%></p>
    
    <div id="QuestionsTableDiv"><p><% Html.RenderPartial("QuestionsTable", ViewData["questions"]); %></p></div>
    
<% } %>

</asp:Content>

